/**
 * <copyright>
 * </copyright>
 *

 */
package br.ufpe.cin.plp.eseml.impl;

import br.ufpe.cin.plp.eseml.EsemlPackage;
import br.ufpe.cin.plp.eseml.ExperimentalObject;
import br.ufpe.cin.plp.eseml.ExperimentalObjects;
import br.ufpe.cin.plp.eseml.ExperimentalObjectsValues;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Experimental Objects</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link br.ufpe.cin.plp.eseml.impl.ExperimentalObjectsImpl#getExperimentalObjects <em>Experimental Objects</em>}</li>
 *   <li>{@link br.ufpe.cin.plp.eseml.impl.ExperimentalObjectsImpl#getExperimentalObjectsValues <em>Experimental Objects Values</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExperimentalObjectsImpl extends MinimalEObjectImpl.Container implements ExperimentalObjects
{
  /**
   * The cached value of the '{@link #getExperimentalObjects() <em>Experimental Objects</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExperimentalObjects()
   * @generated
   * @ordered
   */
  protected EList<ExperimentalObject> experimentalObjects;

  /**
   * The cached value of the '{@link #getExperimentalObjectsValues() <em>Experimental Objects Values</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExperimentalObjectsValues()
   * @generated
   * @ordered
   */
  protected ExperimentalObjectsValues experimentalObjectsValues;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ExperimentalObjectsImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return EsemlPackage.Literals.EXPERIMENTAL_OBJECTS;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ExperimentalObject> getExperimentalObjects()
  {
    if (experimentalObjects == null)
    {
      experimentalObjects = new EObjectContainmentEList<ExperimentalObject>(ExperimentalObject.class, this, EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS);
    }
    return experimentalObjects;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ExperimentalObjectsValues getExperimentalObjectsValues()
  {
    return experimentalObjectsValues;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExperimentalObjectsValues(ExperimentalObjectsValues newExperimentalObjectsValues, NotificationChain msgs)
  {
    ExperimentalObjectsValues oldExperimentalObjectsValues = experimentalObjectsValues;
    experimentalObjectsValues = newExperimentalObjectsValues;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES, oldExperimentalObjectsValues, newExperimentalObjectsValues);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExperimentalObjectsValues(ExperimentalObjectsValues newExperimentalObjectsValues)
  {
    if (newExperimentalObjectsValues != experimentalObjectsValues)
    {
      NotificationChain msgs = null;
      if (experimentalObjectsValues != null)
        msgs = ((InternalEObject)experimentalObjectsValues).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES, null, msgs);
      if (newExperimentalObjectsValues != null)
        msgs = ((InternalEObject)newExperimentalObjectsValues).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES, null, msgs);
      msgs = basicSetExperimentalObjectsValues(newExperimentalObjectsValues, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES, newExperimentalObjectsValues, newExperimentalObjectsValues));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS:
        return ((InternalEList<?>)getExperimentalObjects()).basicRemove(otherEnd, msgs);
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES:
        return basicSetExperimentalObjectsValues(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS:
        return getExperimentalObjects();
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES:
        return getExperimentalObjectsValues();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS:
        getExperimentalObjects().clear();
        getExperimentalObjects().addAll((Collection<? extends ExperimentalObject>)newValue);
        return;
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES:
        setExperimentalObjectsValues((ExperimentalObjectsValues)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS:
        getExperimentalObjects().clear();
        return;
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES:
        setExperimentalObjectsValues((ExperimentalObjectsValues)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS:
        return experimentalObjects != null && !experimentalObjects.isEmpty();
      case EsemlPackage.EXPERIMENTAL_OBJECTS__EXPERIMENTAL_OBJECTS_VALUES:
        return experimentalObjectsValues != null;
    }
    return super.eIsSet(featureID);
  }

} //ExperimentalObjectsImpl
